package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.CustomerDAOInterface;
import org.cuatrovientos.erp.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Holds all the business logic for Customer related management
 * @author VB
 */
public class CustomerBO implements CustomerBOInterface {
	
	// Get log4j logger
	private static final Logger logger = Logger.getLogger(CustomerBO.class);
	
	@Autowired
    private CustomerDAOInterface customerDAO;

	@Override
	public Customer selectById(int id) {
		logger.info("selectById: " + id);
		return customerDAO.selectById(id);
	}

	@Override
	public List<Customer> selectAll() {
		logger.info("selectAll: ");
		return customerDAO.selectAll();
	}

	@Override
	public List<Customer> search(String name) {
		logger.info("search : " + name);
		return customerDAO.search(name);
	}

	@Override
	public void deleteById(int id) {
		logger.info("delete: " + id);
		customerDAO.deleteById(id);
	}

	@Override
	public void insert(Customer customer) {
		logger.info("insert: " + customer);
		customerDAO.insert(customer);
	}

	@Override
	public void update(Customer customer) {
		logger.info("update: " + customer);
		customerDAO.update(customer);
	}
	
	public void delete(Customer customer){
		logger.info("delete: " + customer);
		customerDAO.delete(customer);
	}
}
